﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Windows.Forms;

namespace TunnelBackground
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]

    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码和配置文件中的类名“FireAlarmServices”。
    public class FireAlarmServices : IFireAlarmServices
    {
        string controlPanel;
        string card;
        string device;

        public void ConfirmAlarm(string deviceId,string alarmInfo)
        {
            //FireAlarmTable.dtFireAlarmTable = new DataTable();
            
            var dtFire = from s1 in FireAlarmTable.dtFireAlarmTable.AsEnumerable()
                         where (s1.Field<string>("DeviceID") == deviceId)
                         select s1;
            foreach (var item in dtFire)
            {
                controlPanel = item["ControlPanel"].ToString();
                card = item["Card"].ToString();
                device = item["Device"].ToString();
            }
            ConfirmCommand(controlPanel, card, device,alarmInfo);
            MessageBox.Show(controlPanel);
        }

        public void ConfirmCommand(string controlPanel,string card,string device,string alarmInfo)
        {
            string command = "";
            command = "-确认-  " + DateTime.Now.ToString("HH:mm:ss MM/dd/yyyy") + "  " + alarmInfo + "  控制盘:" + controlPanel + "  卡:" + card + "  器件:" + device;
            COM.SP.Write(command);
        }
    }
}
